<html>
<head><meta charset="utf-8"><title>Adding a new query · t-compiler/help · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/index.html">t-compiler/help</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Adding.20a.20new.20query.html">Adding a new query</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="233367294"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Adding%20a%20new%20query/near/233367294" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Adding.20a.20new.20query.html#233367294">(Apr 06 2021 at 18:34)</a>:</h4>
<p>Okay, so I'm trying to make a new <code>opt_associated_item_def_ids</code> variant of the <code>associated_item_def_ids</code> query, but I keeping getting "<code>DefId</code> isn't local" errors</p>



<a name="233367330"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Adding%20a%20new%20query/near/233367330" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Adding.20a.20new.20query.html#233367330">(Apr 06 2021 at 18:34)</a>:</h4>
<p>Is there something special I need to be doing</p>



<a name="233367653"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Adding%20a%20new%20query/near/233367653" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Adding.20a.20new.20query.html#233367653">(Apr 06 2021 at 18:36)</a>:</h4>
<p>If I do <code>tcx.associated_items(def_id)</code> instead of <code>tcx.opt_associated_item_def_ids</code> it's fine</p>



<a name="233368052"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Adding%20a%20new%20query/near/233368052" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Adding.20a.20new.20query.html#233368052">(Apr 06 2021 at 18:39)</a>:</h4>
<p><span class="user-mention" data-user-id="232957">@Jack Huey</span> can you paste the erorr you're getting?</p>



<a name="233368066"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Adding%20a%20new%20query/near/233368066" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Adding.20a.20new.20query.html#233368066">(Apr 06 2021 at 18:39)</a>:</h4>
<p><span class="user-mention silent" data-user-id="232957">Jack Huey</span> <a href="#narrow/stream/182449-t-compiler.2Fhelp/topic/Adding.20a.20new.20query/near/233367294">said</a>:</p>
<blockquote>
<p>Okay, so I'm trying to make a new <code>opt_associated_item_def_ids</code> variant of the <code>associated_item_def_ids</code> query, but I keeping getting "<code>DefId</code> isn't local" errors</p>
</blockquote>
<p>that sounds like you registered a local provider but not an external one</p>



<a name="233368082"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Adding%20a%20new%20query/near/233368082" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Adding.20a.20new.20query.html#233368082">(Apr 06 2021 at 18:39)</a>:</h4>
<p>take a look at <code>provide_external</code> in rustc_metadata</p>



<a name="233368253"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Adding%20a%20new%20query/near/233368253" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Adding.20a.20new.20query.html#233368253">(Apr 06 2021 at 18:40)</a>:</h4>
<p>yeah, that sounds right</p>



<a name="233368281"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Adding%20a%20new%20query/near/233368281" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Adding.20a.20new.20query.html#233368281">(Apr 06 2021 at 18:40)</a>:</h4>
<p>You'll want to add a new arm to the <code>provide!</code> macro invocation in <code>rustc_metadata</code></p>



<a name="233368645"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Adding%20a%20new%20query/near/233368645" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Adding.20a.20new.20query.html#233368645">(Apr 06 2021 at 18:43)</a>:</h4>
<p>Wait, where exactly? I'm trying to find <code>associated_items</code> as an example</p>



<a name="233368654"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Adding%20a%20new%20query/near/233368654" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Adding.20a.20new.20query.html#233368654">(Apr 06 2021 at 18:43)</a>:</h4>
<p>(since that works in the exact same place)</p>



<a name="233368718"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Adding%20a%20new%20query/near/233368718" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Adding.20a.20new.20query.html#233368718">(Apr 06 2021 at 18:43)</a>:</h4>
<p><code>compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs</code></p>



<a name="233369204"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Adding%20a%20new%20query/near/233369204" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Adding.20a.20new.20query.html#233369204">(Apr 06 2021 at 18:47)</a>:</h4>
<p>the query system is magic</p>



<a name="233372297"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Adding%20a%20new%20query/near/233372297" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cjgillot <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Adding.20a.20new.20query.html#233372297">(Apr 06 2021 at 19:08)</a>:</h4>
<p><span class="user-mention silent" data-user-id="232957">Jack Huey</span> <a href="#narrow/stream/182449-t-compiler.2Fhelp/topic/Adding.20a.20new.20query/near/233367294">said</a>:</p>
<blockquote>
<p>Okay, so I'm trying to make a new <code>opt_associated_item_def_ids</code> variant of the <code>associated_item_def_ids</code> query, but I keeping getting "<code>DefId</code> isn't local" errors</p>
</blockquote>
<p>You can also rename the <code>associated_item_def_ids</code> query and add a proxy method to perform the unwrap. There are examples of such methods in <code>rustc_middle::ty::query</code> module. The compile errors should guide your keyboard <span aria-label="smile" class="emoji emoji-1f642" role="img" title="smile">:smile:</span></p>



<a name="233372366"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Adding%20a%20new%20query/near/233372366" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Adding.20a.20new.20query.html#233372366">(Apr 06 2021 at 19:09)</a>:</h4>
<p>That's basically what I did</p>



<a name="233372501"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Adding%20a%20new%20query/near/233372501" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Adding.20a.20new.20query.html#233372501">(Apr 06 2021 at 19:10)</a>:</h4>
<p>err well</p>



<a name="233372530"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Adding%20a%20new%20query/near/233372530" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Adding.20a.20new.20query.html#233372530">(Apr 06 2021 at 19:10)</a>:</h4>
<p>I guess I kept the existing <code>associated_item_def_ids</code> query</p>



<a name="233374165"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Adding%20a%20new%20query/near/233374165" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Adding.20a.20new.20query.html#233374165">(Apr 06 2021 at 19:22)</a>:</h4>
<p>(But that did make me realize there's a better way to do this)</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>